.class public Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;
.super Ljava/lang/Object;
.source "SizeHashCache.java"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "<K:",
        "Ljava/lang/Object;",
        "V:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;"
    }
.end annotation


# instance fields
.field private cache:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap<",
            "TK;TV;>;"
        }
    .end annotation
.end field

.field private cacheSize:I

.field private head:I

.field private hits:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap<",
            "Ljava/lang/Integer;",
            "TK;>;"
        }
    .end annotation
.end field

.field private rear:I


# direct methods
.method public constructor <init>(I)V
    .locals 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    .line 3
    iput-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->hits:Ljava/util/HashMap;

    const/4 v0, 0x0

    .line 4
    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    .line 5
    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    .line 6
    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cacheSize:I

    .line 7
    iput p1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cacheSize:I

    .line 8
    new-instance p1, Ljava/util/HashMap;

    invoke-direct {p1}, Ljava/util/HashMap;-><init>()V

    iput-object p1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    .line 9
    new-instance p1, Ljava/util/HashMap;

    invoke-direct {p1}, Ljava/util/HashMap;-><init>()V

    iput-object p1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->hits:Ljava/util/HashMap;

    return-void
.end method


# virtual methods
.method public add(Ljava/lang/Object;Ljava/lang/Object;)V
    .locals 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TK;TV;)V"
        }
    .end annotation

    .line 1
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->size()I

    move-result v0

    iget v1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cacheSize:I

    const/4 v2, 0x0

    if-lt v0, v1, :cond_0

    .line 2
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->hits:Ljava/util/HashMap;

    iget v1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .line 3
    iget-object v1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    invoke-virtual {v1, v0}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 4
    iget v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    .line 5
    iget v1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cacheSize:I

    if-lt v0, v1, :cond_0

    iput v2, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    .line 6
    :cond_0
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    invoke-virtual {v0, p1, p2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 7
    iget-object p2, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->hits:Ljava/util/HashMap;

    iget v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v0

    invoke-virtual {p2, v0, p1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 8
    iget p1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    add-int/lit8 p1, p1, 0x1

    iput p1, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    .line 9
    iget p2, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cacheSize:I

    if-lt p1, p2, :cond_1

    iput v2, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    :cond_1
    return-void
.end method

.method public clear()V
    .locals 1

    const/4 v0, 0x0

    .line 1
    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->head:I

    iput v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->rear:I

    .line 2
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->hits:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->clear()V

    .line 3
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->clear()V

    return-void
.end method

.method public getValue(Ljava/lang/Object;)Ljava/lang/Object;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TK;)TV;"
        }
    .end annotation

    .line 1
    iget-object v0, p0, Lcom/estrongs/android/pop/netfs/utils/SizeHashCache;->cache:Ljava/util/HashMap;

    invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p1

    return-object p1
.end method
